package com.itcast.plane.modoule.picture.controller;

import com.itcast.plane.modoule.picture.service.PictureService;
import com.itcast.plane.util.JsonResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/picture")
public class PictureController {

    @Resource
    private PictureService pictureService;

    @GetMapping("/download")
    public void download(@RequestParam int id, HttpServletResponse response){
        pictureService.fileDownload(response,id);
    }

    @PostMapping("/upload")
    public JsonResult upload(@RequestBody MultipartFile file){
        return pictureService.upload(file);
    }
}
